package com.hmy.cornpestdet.controller;

import com.hmy.cornpestdet.service.UserLoginRegisterService;
import com.hmy.cornpestdet.utils.Result;
import com.hmy.cornpestdet.vo.UserLoginVo;
import com.hmy.cornpestdet.vo.UserRegisterVo;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;

@RestController
public class UserLoginRegisterController {
    @Autowired
    UserLoginRegisterService userLoginRegisterService;

    @PostMapping("/login/submit")
    public Result login(@RequestBody UserLoginVo userLoginVo){
        return userLoginRegisterService.login(userLoginVo);
    }
    @GetMapping("/login/getCode")
    public void generateCode(HttpServletResponse response) throws IOException {
        userLoginRegisterService.generateCode(response);
    }
    @PostMapping("/register/submit")
    public Result register(@RequestBody UserRegisterVo userRegisterVo){
        return userLoginRegisterService.register(userRegisterVo);
    }



}
